/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TimeRecording.reporting;

import TimeRecording.business.DaisyChainUtilities;
import java.awt.Image;
import java.text.DecimalFormat;
import java.util.Formatter;
import java.util.HashMap;
import javax.swing.ImageIcon;

/**
 *
 * @author david
 */
public class ReportingUtilities {

    private static DecimalFormat TWO_PLACES =
            new DecimalFormat("###0.00;-###0.00");

    private static boolean suppressWatermark;

    public static boolean isSuppressWatermark() {
        return suppressWatermark;
    }

    public static void setSuppressWatermark(boolean suppressWatermark) {
        ReportingUtilities.suppressWatermark = suppressWatermark;
    }

    private static Image watermark;

    public Image getWatermark() {
        if (watermark == null) {
            watermark = new ImageIcon(getClass().getResource(
                    "/images/LargeVeryLightDaisyBottomRight.jpg")).getImage();
        }
        return watermark;
    }

    public HashMap<String, Object> getBasicParameters() {
        HashMap<String, Object> parameters = new HashMap<String, Object>();

        if (!suppressWatermark) {
            parameters.put("WATERMARK", getWatermark());
        }
//        parameters.put("SUBREPORT_DIR", "/reports/");
        return parameters;
    }

    public static String twoDecimals(Double value) {
        return TWO_PLACES.format(value);
    }

    public static String twoDecimalsNullZero(Double value) {
        if (value == null || value == 0.0 || value == -0.0) {
            return "";
        } else {
            return TWO_PLACES.format(value);
        }
    }
}
